#include <iostream>
#include "mcu_client.h"
#include "mcu_api.h"
#include "error.h"

using std::cout;
using std::endl;
using std::string;

namespace mcu {

Client::Client(string url) {
  _url = url;
}

error Client::CreateEventQueue() {
  return XmlRpc::CreateEventQueue(_url, &_queueID);
}


error  Client::DeleteEventQueue() {
  return XmlRpc::DeleteEventQueue(_url, _queueID);
}


error Client::CreateConference(string& tags, int vad, int rate) {
  return XmlRpc::CreateConference(_url, tags, vad, rate, _queueID , &_confID);
}

error Client::DeleteConference() {
  return XmlRpc::DeleteConference(_url,_confID);
}


error  Client::CreateMosaic(int comp, int size) {
  return XmlRpc::CreateMosaic(_url, _confID, comp, size, &_mosaicID);
}

error Client::DeleteMosaic() {
  return XmlRpc::DeleteMosaic(_url, _confID, _mosaicID);
}


error Client::CreateSidebar() {
  return XmlRpc::CreateSidebar(_url,_confID, &_sidebarID);
}

error Client::DeleteSidebar() {
  return XmlRpc::DeleteSidebar(_url, _confID, _sidebarID);
}

error Client::CreateParticipant(string& sname, string& token, int type) {
  return XmlRpc::CreateParticipant(_url, _confID, _mosaicID, _sidebarID, sname, token, type, &_partID);
}

error Client::DeleteParticipant() {
  return XmlRpc::DeleteParticipant(_url, _confID, _partID);
}

error Client::StartPublishing(string& rtmpServer, int port, string& app, string& stream) {
  return XmlRpc::StartPublishing(_url, _confID, rtmpServer, port, app, stream, &_publisherID);
}

error Client::StopPublishing() {
  return XmlRpc::StopPublishing(_url, _confID, _publisherID);
}



error Client::StartReceiving(int media, RtpMap& rtpMap, RtpMap& aptMap) {
  return XmlRpc::StartReceiving(_url, _confID, _partID, media, rtpMap, aptMap,  &_port);
}

error Client::StopReceiving(int media) {
  return XmlRpc::StopReceiving(_url, _confID, _partID, media);
}


}
